home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / COM / LineShare 3.3.1 folder.sit / LineShare 3.3.1 folder / LineShare 3.3.1 / LineShare Scripts / Fax Class2.0&ARA&Data < prev    next >
Text File  |  1995-11-11  |  8KB  |  431 lines

  1. ! Version 3.3
  2. !
  3. !$ Use this script with Class 2.0 fax software, ARA 1.0 or 2.0,
  4. !$ and a BBS, E-mail or other communication server software
  5. !
  6. !$ Make sure that your modem and fax software support Class 2.0
  7. !$ (US Robotics modems, CommuniGate FaxGate)
  8.  
  9. ^# Modem:
  10. ^3 Error Correction: = Bool("Enabled"="AUTO","Disabled"="NORM") "NORM"
  11. ^4 Handshake wires: = Bool("CTS+DTR"="&D0","CTS only"="&D2") "&D2"
  12. ^5 Answer On: = Enum("Never"="0","1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
  13. ^6 Data Port Speed: = Enum("9600","19200","38400","57600") "19200"
  14. ! ------------------------------------------
  15. ! Resetting the modem:
  16. ! ------------------------------------------
  17. @Hangup
  18.   SetFCLASS "0,1,2.0"
  19.   SetTries 2
  20.   Flush
  21.   HsReset 0,0,0,0,0,0
  22.   DtrSet
  23. !
  24. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  25. ! to enter the command mode
  26. !
  27. @Label 1
  28.   matchclr
  29.   matchstr 1 2 "OK¥r¥n"
  30.   write "ATH0V1Q0E1¥r"
  31.   matchread 20
  32.   ChrDelay 1
  33.   Write "+++"
  34.   ChrDelay 0
  35.   DtrClear
  36.   SBreak
  37.   DtrSet
  38. !
  39.   DecTries
  40.   IfTries 0 1
  41. !
  42. ! OSErr -6019 "Modem error - the modem is not responding"
  43. !
  44.   exit -6019
  45. @Label 2
  46.   SetVar A "&F"
  47.   GetOption A "DFLT" 3
  48. @Label 3
  49.   write "AT^A+FCLASS=0¥r"
  50.   Jsr 100
  51.   exit 0
  52.  
  53. @Label 6
  54.   Say "This script cannot be used with this modem"
  55.   ifOriginate 7
  56.   pause 1800
  57. @Label 7
  58.   exit -6019
  59. ! ------------------------------------------
  60. !    Receiving incoming calls
  61. ! ------------------------------------------
  62. @ANSWER
  63. @Label 10
  64. !
  65. ! Set the modem preferred speed first
  66.   SerReset Val("^6"),0,8,1
  67.   Jsr 80
  68. !
  69. ! Set the common options
  70.   Jsr 70
  71. !
  72. ! Set the communication options:
  73. ! ・ Normal/AUTO Connection
  74. ! ・ HW flow control  (for ARA, Fax should not use a handshake on receiving)
  75. ! ・ CONNECT <DCE speed> or CARRIER/CONNECT
  76. !
  77.   GetOption A "HWHS" 6
  78.   GetOption B "^3" 6
  79.   GetOption C "LNRS" 6
  80.   Write "AT^A^B^C¥r"
  81.   Jsr 100
  82. !
  83. ! Set Fax parameters: LID, DCC,BOR
  84. !
  85.   Write "AT+FCLASS=2.0¥r"
  86.   Jsr 100
  87.   Write "AT+FCR=1;+FAA=1;+FLO=2;+FNR=1,1,1¥r"
  88.   Jsr 100
  89. !
  90. ! Set FLID - sometimes it can fail
  91. !
  92.   GetCommand A "Fax" "+FLI"
  93.   Write "AT^A¥r"
  94.   Jsr 100
  95.   Write "AT+FCC=1,5,0,2,0,0,0,0¥r"
  96.   Jsr 100
  97. !
  98. ! Set FCC - sometimes it can fail
  99. !
  100.   GetCommand A "Fax" "+FCC"
  101.   Write "AT^A¥r"
  102.   Jsr 100
  103.   GetCommand A "Fax" "+FBO"
  104.   Write "AT^A¥r"
  105.   Jsr 100
  106.  
  107. !
  108. ! Get the Speaker options
  109.   GetCommand B "Fax" "M"
  110.   GetCommand C "Fax" "L"
  111. !@Label 13
  112.    SetVar A "S0=^5"
  113. !
  114. ! Answer call after <A> rings
  115.   Write "AT^A^B^C¥r"
  116.   Jsr 100
  117. !
  118. ! Everything is ready - let's sit and wait for a call
  119. ! We'll wait for 2 minutes, then reinitiate the modem
  120.   Note "Waiting for a Fax/ARA/Data callノ"
  121.   Jsr 90
  122.   IfStr D 40 "FAX"
  123.   IfStr D 20 "DATA"
  124.   Jump 10
  125.  
  126. !
  127. ! Data connection has been established (we read "CONNECT")
  128. ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
  129. ! if it was an incoming call, put the "RING" before the "CONNECT"
  130. !
  131. @Label 20
  132.   IfOpen "Data" 21
  133.   Jump 30
  134. @Label 21
  135.   IfOpen "ARA" 22
  136.   Jump 35
  137. @Label 22
  138.   Note "Waiting for an ARA frame"
  139.   MatchClr
  140.   MatchStr 1 23 "^$¥r"
  141.   MatchStr 2 28 "¥08¥01¥03¥14¥04¥03¥00¥08¥250¥16¥03"
  142.   MatchStr 3 29 "¥01¥27¥02¥29¥01¥02¥01¥06"
  143.   MatchRead 40
  144.   Jump 24
  145. @Label 23
  146.   QueueInput "^$¥r"
  147. @Label 24
  148.   Note "Non-ARA call"
  149.   Jump 35
  150.  
  151. @Label 28
  152.   Note "ARA 1.0 call"
  153.   Jump 30
  154. @Label 29
  155.   Note "ARA 2.0 call"
  156.   Jump 30
  157.  
  158. @Label 30
  159.   QueueInput "¥r¥nCARRIER ^B¥r¥n"  
  160.   IfStr A 31 "NONE"
  161.   IfStr A 31 "None"
  162.   QueueInput "¥r¥nREL¥r¥n"
  163. @Label 31
  164.   IfOriginate 32
  165.   QueueInput "¥r¥nRING¥r¥n"
  166. @Label 32
  167.   Attach "ARA" (DTR)
  168.  
  169. @Label 35
  170.   GetSReg C "DATA" 4
  171.   QueueInput "¥r^CCONNECT ^B¥r^C"
  172.   ifOriginate 36
  173.   QueueInput "¥r^CRING¥r^C"
  174. @Label 36
  175.   HsReset 0,1,0,0,0,1
  176.   Attach "Data" (DTR,Escape,Break)
  177.  
  178. !
  179. ! Fax connection has been established (we read "+FCON")
  180. ! Put the +FCON back to the buffer,
  181. ! if it was an incoming call, put the "RING" before the "+FCON"
  182. ! Attach the "Fax" subPort
  183. !
  184. @Label 40
  185.   QueueInput "¥r¥n+FCO"
  186.   ifOriginate 41
  187.   QueueInput "¥r¥nRING¥r¥n"
  188. @Label 41
  189.   Attach "Fax" (DTR,Reset,IdleLimit=30)
  190.  
  191. ! ------------------------------------------
  192. ! Originating a call through the "ARA" subport
  193. ! ------------------------------------------
  194. @ORIGINATE "ARA"
  195.   SerReset Val("^6"),0,8,1
  196.   Jsr 80
  197. !
  198. ! Set the common options
  199.   Jsr 70
  200.   Jsr 60
  201. !
  202. ! Set the communication options:
  203. ! ・ Normal Connection
  204. ! ・ HW flow control
  205. ! ・ CONNECT <DCE speed> or CARRIER/CONNECT
  206. !
  207.   GetOption A "HWHS" 6
  208.   GetOption B "^3" 6
  209.   GetOption C "LNRS" 6
  210.   Write "AT^A^B^C¥r"
  211.   Jsr 100
  212. !
  213. ! dial the number
  214.   Write "ATD^1¥r"
  215. !
  216. ! Wait for a modem response
  217.   Jsr 92
  218.   IfStr D 30 "DATA"
  219.   Write "¥r"
  220.   Exit -6019
  221.  
  222. ! ------------------------------------------
  223. ! Originating a call through the "DATA" subport
  224. ! ------------------------------------------
  225. @ORIGINATE "Data" ("¥r¥nLineShare Line is Busy¥r¥nBUSY¥r¥n")
  226.   SerReset Val("^6"),0,8,1
  227.   Jsr 80
  228. !
  229. ! Set the common options
  230.   Jsr 70
  231. !
  232. ! Set the communication options:
  233. ! ・ Normal Connection
  234. ! ・ HW flow control
  235. ! ・ CONNECT <DCE speed> or CARRIER/CONNECT
  236. !
  237.   GetOption A "HWHS" 6
  238.   GetOption B "^3" 6
  239.   GetOption C "LNRS" 6
  240.   Write "AT^A^B^C¥r"
  241.   Jsr 100
  242. !
  243. ! dial the number
  244.   Write "ATD^1¥r"
  245.   HsReset *
  246. !
  247. ! Wait for a modem response
  248.   Jsr 92
  249.   IfStr D 35 "DATA"
  250.   Write "¥r"
  251.   Exit -6019
  252.  
  253. ! ------------------------------------------
  254. ! Originating a call through the "Fax" subPort
  255. ! ------------------------------------------
  256. @ORIGINATE "Fax" ("¥r¥nLineShare Line is Busy¥r¥nBUSY¥r¥n")
  257. !
  258. ! Set the "Fax" speed
  259. !
  260.   SerReset 19200,0,8,1
  261.   Jsr 80
  262. !
  263. ! Set the common options
  264. !
  265.   Jsr 70
  266. !
  267. ! Now emit all commands that the application has sent to that port,
  268. ! except "V" and "+FCLASS"
  269. !
  270.   EmitClear "V","+FCLASS"
  271.   Jsr 60
  272.   Write "AT+FCLASS=2.0¥r"
  273.   Jsr 100
  274.   HsReset *
  275. !
  276. ! dialing the number
  277.   Write "ATD^1¥r"
  278.   Jsr 90
  279.   IfStr D 40 "FAX"
  280.   Write "¥r"
  281.   Exit -6019
  282. !
  283. ! This section emits all modem commands sent from the client application
  284. ! For each set of commands the "OK" answer is awaited
  285. !
  286. @Label 60
  287.   EmitStart
  288. @Label 61
  289.   EmitCommand 62
  290.   Jsr 100
  291.   Jump 61
  292. @Label 62
  293.   return
  294. !
  295. ! This section initiates the modem before ANSWER and ORIGINATEs:
  296. ! reset on Dtr drop + DCD valid
  297. ! Verbal responses mode, no echo 
  298. !
  299. @Label 70
  300.   Write "AT^4&C1V1E0¥r"
  301.   Jsr 100
  302.   return 
  303.  
  304. !
  305. ! This section syncronize the modem after the serial port speed switching
  306. !
  307. @Label 80
  308.   ChrDelay 1
  309.   Write "AT¥r"
  310.   ChrDelay 0
  311.   Jsr 100
  312.   return
  313. !
  314. ! Error codes
  315. @Label 81
  316.   exit -6020
  317. @Label 82
  318.   exit -6022
  319. @Label 83
  320.   exit -6021
  321. @Label 84
  322.   exit -6023
  323.  
  324. @Label 85
  325.   Note "Data Call"
  326.   Jump 92
  327.  
  328. !
  329. ! Processing CONNECT message:
  330. ! If the speed has not been set to ^B with a CARRIER message, take
  331. ! the speed from the CONNECT message
  332. !
  333. @Label 86
  334.   ifStr B 87 ""
  335.   return
  336. @Label 87
  337.   SetVar B "^$"
  338.   return 
  339.  
  340. !
  341. ! This subroutine waits for the modem response
  342. ! On exit, ^D contains the result code: "FAX" or "DATA"
  343. ! ^A contains the protocol used
  344. ! ^B contains the carrier speed
  345. ! If modem reports an error, the scripts exits with an error code
  346. !
  347. !
  348. ! Fax connection was established
  349. !
  350. @Label 88
  351.   SetVar D "FAX"
  352.   return
  353.  
  354. @Label 89
  355.   Note "Ringノ"
  356.   Jump 91
  357.  
  358. @Label 90
  359.   SetVar A "NONE"
  360.   SetVar B ""
  361.   MatchClr
  362.   Matchstr 1 88 "+FCO"
  363.   Matchstr 2 92 "+FDM"
  364.  
  365.   Matchstr 6 89 "RING¥r¥n"
  366.   Matchstr 10 82 "BUSY¥r¥n"
  367.   MatchStr 11 83 "NO CARRIER¥r¥n"
  368.   MatchStr 12 84 "NO ANSWER¥r¥n"
  369.   MatchStr 13 81 "NO DIALTONE¥r¥n"
  370. @Label 91
  371.   Matchread 1200
  372.   SetVar D "NONE"
  373.   return
  374.  
  375. @Label 92
  376.   SetVar A "NONE"
  377.   SetVar B ""
  378.   MatchClr
  379.   Matchstr 1 94 "CARRIER ^$¥r¥n"
  380.   Matchstr 2 95 "PROTOCOL: ^$¥r¥n"
  381.   Matchstr 4 96 "CONNECT ^$/"
  382.   Matchstr 5 98 "CONNECT ^$¥r¥n"
  383.   Matchstr 10 82 "BUSY¥r¥n"
  384.   MatchStr 11 83 "NO CARRIER¥r¥n"
  385.   MatchStr 12 84 "NO ANSWER¥r¥n"
  386. @Label 93
  387.   Matchread 1200
  388.   SetVar D "NONE"
  389.   return
  390.  
  391. @Label 94
  392.   SetVar B "^$"
  393.   Jump 93
  394.  
  395. @Label 95
  396.   SetVar A "^$"
  397.   Jump 91
  398.  
  399. ! CONNECT xxxx/XXXX was detected
  400. @Label 96
  401.   Jsr 86
  402.   MatchClr
  403.   MatchStr 1 97 "^$¥r¥n"
  404.   MatchRead 10
  405. @Label 97
  406.   SetVar A "^$"
  407.   SetVar D "DATA"
  408.   return
  409.  
  410. ! CONNECT xxx was detected
  411. @Label 98
  412.   Jsr 86
  413.   SetVar D "DATA"
  414.   return
  415.  
  416. !
  417. ! Processing the AT command:
  418. ! OK -> proceed
  419. ! ERROR or TimeOut ->exit -6019
  420. ! It can be called AFTER the "Write" command, since LineShare buffers input
  421. !
  422. @Label 100
  423.   MatchClr
  424.   MatchStr 1 102 "OK¥r¥n"
  425.   MatchStr 2 101 "ERROR¥r¥n"
  426.   MatchRead 20
  427. @Label 101
  428.   Exit -6019
  429. @Label 102
  430.   return
  431.